// 一些常规的验证

// 手机号验证
let validatorPhone = async (rule, value) => {
  let regPhone = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
  if (!value) {
    return Promise.reject('请输入手机号')
  } else if (!regPhone.test(value)) {
    return Promise.reject('请输入正确的手机号')
  } else {
    return Promise.resolve()
  }
}
// 密码验证
var password = ''
let validatorPass1 = async (rule, value) => {
  password = value
  let regPhone = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,20}$/
  if (!value) {
    return Promise.resolve()
  }
  if (!regPhone.test(value)) {
    return Promise.reject('密码为8-20位数字和英文组合')
  } else {
    return Promise.resolve()
  }
}
let validatorPass = async (rule, value) => {
  password = value
  let regPhone = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,20}$/
  if (!value) {
    return Promise.reject('请输入密码')
  } else if (!regPhone.test(value)) {
    return Promise.reject('密码为8-20位数字和英文组合')
  } else {
    return Promise.resolve()
  }
}
// 确认密码
let validtorConfirmPass = async (rule, value) => {
  if (!value) {
    return Promise.reject('请输入确认密码')
  } else if (value != password) {
    return Promise.reject('两次输入密码不一致，请重新输入！')
  } else {
    return Promise.resolve()
  }
}
let validtorConfirmPass1 = async (rule, value) => {
  console.log('测试', value, '1', password)
  if (value != password) {
    return Promise.reject('两次输入密码不一致，请重新输入！')
  } else {
    return Promise.resolve()
  }
}

// 这两个准备 用a-input-number验证，但是form表单验证不了
// 时间验证
// 价格验证
let validtorPrice = async (rule, value) => {
  let regPrice = ''
  if (!value) {
    return Promise.reject('请输入价格')
  } else if (!regPrice.test(value)) {
    return Promise.reject('')
  } else {
    return Promise.resolve()
  }
}

export { validatorPass, validatorPass1, validtorConfirmPass, validtorConfirmPass1, validatorPhone, validtorPrice }
